# include "scene.h"
# include <stdio.h>
# include <errno.h>

extern FILE *file_open(FILE *lptr, const char *file, unsigned int t_cnt, unsigned int nfreq)
    {
     FILE *ptr;
     char fname[MAX_FNAME_LEN];
     int _errno;

     if(file == (char *)0) return stdout;

     sprintf(fname, "%02d.%s.%09d-%09d.txt", RUN_CNT, file, t_cnt, t_cnt+nfreq-1);

     if( (ptr = (FILE *)fopen(fname, "w")) != (FILE *)0) return ptr;

     _errno = errno;
     fprintf(lptr, "WARNING:: In 'file_open()': Unable to open '%s' for writing.\n\tSystem errno = %d.\n\tRedirecting output to 'stdout'.\n",\
             fname, _errno);

     return stdout;
    }
